package com.hsgene.product.constants;

/**
 * 商品状态枚举
 *
 * @author wangbing
 * @version 1.0, 2018/10/18
 */
public enum CommodityStatus {

    /**
     * 商品状态枚举
     */
    INCOMPLETE(0, "待补充"), NON_USED(1, "未使用"), USED(2, "已使用");

    private final int code;

    private final String desc;

    public int getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    CommodityStatus(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static CommodityStatus getEnum(int code) {
        for (CommodityStatus status : values()) {
            if (status.code == code) {
                return status;
            }
        }

        throw new IllegalStateException("非法商品状态code值：" + code);
    }
}
